Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EventHub client extension methodS #7034

Merged
merged 3 commits into from
Jul 29, 2019
Merged

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Jul 26, 2019

Also adjust IAzureClientFactoryBuilderWithCredential type name.

@pakrym pakrym requested a review from jsquire July 26, 2019 21:34
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor suggestion, but that may be based on an incorrect assumption. Otherwise, LGTM!

@@ -8,6 +8,6 @@ namespace Azure.Core.Extensions
{
public interface IAzureClientFactoryBuilder
{
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TClient> clientFactory) where TOptions : ClientOptions;
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TClient> clientFactory) where TOptions : class;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider making the options always have a default constructor and using that constraint, or is that unimportant down the line?

Copy link
Contributor Author

@pakrym pakrym Jul 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, they almost never have a default constructor. Instead, the guidelines prescribe having a constructor with ServiceVersion parameter defaulted to latest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. Forgot about that due to the deviation in the Event Hubs service design.

/// <summary>
/// Registers a <see cref="EventHubClient"/> instance with the provided <paramref name="connectionString"/> and <paramref name="eventHubPath"/>
/// </summary>
public static IAzureClientBuilder<EventHubClient, EventHubClientOptions> AddEventHubClient<TBuilder>(this TBuilder builder, string connectionString, string eventHubPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may not have context enough to be reading this entirely correctly, but I believe this limits scenarios to:

  • Here's a connection string (with path embedded) and a set of options
  • Here's a connection string and an event hub path, but you have to use default options (I suspect this will be the majority case)

If that is the case, I'd suggest that we also allow:

  • Here's a connection string, event hub path, and set of options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IAzureClientBuilder return type has a ConfigureOptions(options => {}) method on it.

So to add a client and configure its options:

builder.AddEventHubClient("connectionString", "path").ConfigureOptions(options => {} );

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Works for me!

@pakrym pakrym merged commit 506f75f into Azure:master Jul 29, 2019
@pakrym pakrym deleted the pakrym/eh-ext branch July 29, 2019 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants